<template>
	<view>
		<map id="map1" :longitude="longitude" :latitude="latitude" :markers="markers" :polyline="polyline" scale="13"
			zIndex="0">
		</map>
		<scroll-view scroll-y class="scroll">
			<view class="header" :style="{backgroundColor:'rgba(255, 255, 255, '+slideHeight+')'}">
				<view class="title">
					<!-- #ifndef MP-ALIPAY -->
					<view @click="back" class="return">
						<view class="icons">
							<u-icon name="arrow-left" size="20" bold></u-icon>
						</view>
					</view>
					<!-- #endif -->
					<text>{{title}}</text>
				</view>
			</view>
			<view class="content">
				<view class="body">
					<view class="address">
						<view class="form-item hm-border-b hm-m-b-20">
							派送距离
							<view class="right">
								约<text class="hm-col-0 hm-font-b">{{order.distance.text}}</text>
							</view>
						</view>
						<view class="address-left">
							<view class="hm-m-t-20">
								<view class="icons fa">发</view>
							</view>
							<view @click="overturn" class="overturn">
								<view class="icons">
									<u-icon name="/static/up-down.png" size="20" bold></u-icon>
								</view>
							</view>
							<view>
								<view class="icons shou">收</view>
							</view>
						</view>
						<view class="address-right">
							<view class="detail u-line-1">{{address.start.address}}</view>
							<view class="phone hm-p-b-25">{{address.start.phone}}</view>
							<view class="detail u-line-1 hm-p-t-25 hm-border-t">{{address.receive.address}}</view>
							<view class="phone hm-p-b-25">{{address.receive.phone}}</view>
						</view>
						<view class="form-item hm-border-t">
							<view @click="startTimeOpen" class="w-50 hm-border-r">
								<view class="hm-dis-block-inline">
									<u-icon name="clock" size="14" bold></u-icon>
								</view>
								<text class="hm-p-lr-5">{{start_time_text}}</text>
								<view class="hm-dis-block-inline">
									<u-icon name="arrow-right" size="12" bold></u-icon>
								</view>
							</view>
							<view @click="messageShow" class="w-50">
								<view class="u-line-1 hm-p-lr-10">
									<view class="hm-dis-block-inline">
										<u-icon name="edit-pen" size="14" bold></u-icon>
									</view>
									<text class="hm-p-lr-5">{{remark?remark:'备注配送要求'}}</text>
									<view class="hm-dis-block-inline">
										<u-icon name="arrow-right" size="12" bold></u-icon>
									</view>
								</view>
							</view>
						</view>
					</view>
					<view class="hm-p-lr-30 hm-bg-f hm-br-18 hm-m-t-20">
						<view class="form-item hm-border-b">
							标准派送
							<view class="right">
								预计<text class="hm-col-0 hm-font-b">{{order.estimate_time.text}}</text>送达
							</view>
						</view>
						<view class="form-item hm-border-b">
							物品信息
							<view @click="goodsShow" class="right">
								<text v-if="goods.name">{{goods.name}}</text>
								<text v-else class="hm-col-error">需要完善</text>
								<view class="hm-dis-block-inline hm-m-l-5">
									<u-icon name="arrow-right" size="14" bold></u-icon>
								</view>
							</view>
						</view>
						<view class="form-item hm-border-b">
							返程订单
							<view class="right">
								<u-radio-group v-model="is_return" placement="row" activeColor="#ff6900">
									<u-radio @change="setReturn(1)" name="1" label="需要"></u-radio>
									<view class="hm-dis-block-inline hm-m-l-30">
										<u-radio @change="setReturn(0)" name="0" label="不需要"></u-radio>
									</view>
								</u-radio-group>
							</view>
						</view>
						<view class="form-item hm-border-b">
							指派骑手
							<view class="right">
								<text class="hm-col-light">无权指派</text>
								<view class="hm-dis-block-inline hm-m-l-5">
									<u-icon name="arrow-right" size="14" bold></u-icon>
								</view>
							</view>
						</view>
						<view class="form-item hm-border-b">
							优惠券
							<view class="right">
								<text class="hm-col-light">无可用券</text>
								<view class="hm-dis-block-inline hm-m-l-5">
									<u-icon name="arrow-right" size="14" bold></u-icon>
								</view>
							</view>
						</view>
						<!-- 技术支持 -->
						<view class="hm">
							{{applet.copyright}} <text class="v">V{{applet.version}}</text>
						</view>
					</view>
				</view>
			</view>
			<view class="hm-footer-fixed">
				<view class="footer-but">
					<view class="but-left">
						<text class="price"><text>￥</text>{{order.pay_price}}</text>
						<text v-if="order.total_price > order.pay_price"
							class="hm-font-zhx hm-m-l-10 hm-font-28 hm-col-tips hm-fl">
							{{order.total_price}}
						</text>
						<view class="icons">
							<view class="hm-dis-block-inline">
								<u-icon name="arrow-down" size="8" bold color="#ffffff"></u-icon>
							</view>
						</view>
					</view>
					<view class="but-right" @click="cashier_show = true">
						立即下单
					</view>
				</view>
			</view>
		</scroll-view>
		<!-- 支付收银台 -->
		<u-popup :show="cashier_show" @close="cashier_show = false" mode="center" round="8" :closeable="true">
			<view class="hm-popup">
				<view class="hm-p-b-20 hm-border-b">在线支付</view>
				<view class="hm-p-tb-50 hm-text-center">
					<view class="hm-font-b hm-col-0">
						￥<text class="hm-font-100">{{order.pay_price}}</text>
					</view>
					<view class="hm-font-28 hm-col-content">订单支付</view>
				</view>
				<!-- #ifdef H5 || MP-WEIXIN -->
				<view v-if="mp=='weixin'||mp=='other'" class="hm-p-20 hm-border-t hm-font-26" @click="setPay(1)">
					<view class="hm-dis-block-inline hm-m-r-15">
						<u-icon name="weixin-circle-fill" size="20" color="#19be6b"></u-icon>
					</view>
					微信
					<view class="hm-fr hm-dis-block-inline">
						<u-icon name="checkbox-mark" v-if="pay_mode==1" size="25" color="#fa3534"></u-icon>
					</view>
				</view>
				<!-- #endif -->
				<!-- #ifdef H5 || MP-ALIPAY -->
				<view v-if="mp=='alipay'||mp=='other'" class="hm-p-20 hm-border-t hm-font-26" @click="setPay(4)">
					<view class="hm-dis-block-inline hm-m-r-15">
						<u-icon name="zhifubao-circle-fill" size="20" color="#2979ff"></u-icon>
					</view>
					支付宝
					<view class="hm-fr hm-dis-block-inline">
						<u-icon name="checkbox-mark" v-if="pay_mode==4" size="25" color="#fa3534"></u-icon>
					</view>
				</view>
				<!-- #endif -->
				<view class="hm-p-20 hm-border-t hm-font-26" @click="setPay(2)">
					<view class="hm-m-r-15 hm-dis-block-inline">
						<u-icon name="red-packet-fill" size="20"
							:color="Number(userInfo.money) < Number(order.pay_price)?'#c0c4cc':'#FF6900'"></u-icon>
					</view>
					<text :class="Number(userInfo.money) < Number(order.pay_price)?'hm-col-light':''">
						余额(<text
							:class="Number(userInfo.money) < Number(order.pay_price)?'':'hm-col-error'">￥{{userInfo.money}}</text>)
					</text>
					<view class="hm-fr hm-dis-block-inline">
						<u-icon name="checkbox-mark" v-if="pay_mode==2" size="25" color="#fa3534"></u-icon>
						<text v-if="Number(userInfo.money) < Number(order.pay_price)" class="hm-col-light">余额不足</text>
					</view>
				</view>
				<view class="hm-border-t hm-p-t-50">
					<view class="hm-p-lr-b25">
						<u-button shape="circle" color="#ff6900" @click="subMsg" text="确认支付"></u-button>
					</view>
				</view>
			</view>
		</u-popup>
		<u-picker :show="start_time_show" ref="startTimePicker" :defaultIndex="indexs" :columns="start_time_picker"
			@cancel="startTimeClose" @confirm="startTime" @change="startTimeHandler"></u-picker>
		<u-popup :show="message_show" round="18" @close="messageShow" closeable>
			<view class="hm-p-20 hm-bg-f hm-br-18">
				<view class="hm-p-b-20">备注信息</view>
				<u--textarea v-model="remark" placeholder="请输入配送要求等信息" maxlength="100" count focus></u--textarea>
				<view class="hm-p-t-50">
					<view class="hm-p-lr-b25">
						<u-button shape="circle" color="#ff6900" @click="messageShow" text="确定"></u-button>
					</view>
				</view>
			</view>
		</u-popup>
		<u-popup :show="goods_show" @close="goodsShow" round="18" closeable>
			<view class="hm-p-20 hm-bg-f hm-br-18">
				<view class="hm-p-b-20 hm-border-b hm-col-0">物品信息</view>
				<scroll-view scroll-y class="goods-scroll">
					<view class="hm-m-t-20">
						物品类型<text class="hm-col-tips hm-m-l-10">(必选)</text>
						<view class="hm-dis-block-inline hm-m-l-10">
							<u-icon name="info-circle" color="#909193"></u-icon>
						</view>
					</view>
					<view class="goods-type">
						<view @click="setGoodsName(item.name)" class="item" v-for="(item,index) in goods_list"
							:key="index" :class="goods.name == item.name?'selected':'default'">
							{{item.name}}
						</view>
					</view>
					<view class="hm-m-t-20">保温箱</view>
					<view class="goods-insured">
						<view @click="setGoodsIncubator(0)" class="item" :class="goods.is_incubator==0?'selected':'default'">
							不需要
						</view>
						<view @click="setGoodsIncubator(1)" class="item" :class="goods.is_incubator==1?'selected':'default'">
							需要
						</view>
					</view>
					<view class="hm-m-t-20">
						物品保价
						<text class="hm-col-error hm-font-24 hm-fr hm-m-r-20 hm-m-t-5">
							贵重或易损易坏物品建议保价
						</text>
					</view>
					<view class="goods-insured">
						<view @click="setGoodsInsured(index)" class="item" v-for="(item,index) in insured_list"
							:key="index" :class="insured_index == index?'selected':'default'">
							<view class="value">价值￥{{index>0?insured_list[index-1].value:'1'}}-{{item.value}}</view>
							<view class="price">保价费￥{{item.price}}元</view>
						</view>
					</view>
					<view class="hm-m-t-20">
						物品重量
					</view>
					<view class="goods-weight">
						<view @click="setGoodsWeight(index)" class="item" v-for="(item,index) in weight_list"
							:key="index" :class="weight_index == index?'selected':'default'">
							<view class="value">{{index>0?weight_list[index-1].value:'0'}}-{{item.value}}kg</view>
							<view class="price">￥{{item.price}}元</view>
						</view>
					</view>
					<!-- 技术支持 -->
					<view class="hm">
						{{applet.copyright}} <text class="v">V{{applet.version}}</text>
					</view>
				</scroll-view>
				<view class="hm-p-t-50">
					<view class="hm-p-lr-b25">
						<u-button shape="circle" color="#ff6900" @click="goodsShow" text="确定"></u-button>
					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	const App = getApp();
	export default {
		data() {
			return {
				applet: {},
				title: '帮我送',//页面标题
				slideHeight: false,
				order_mode: 0,//订单模式
				address: null,//缓存地址
				userInfo: {},
				tpl: null, //模板消息
				mp: '', //平台类型
				order: {},//预生成订单
				
				//地图参数
				markers: null,//标记点
				polyline: null,//路线
				latitude: '',//中心纬度
				longitude: '',//中心经度
				//收银台
				cashier_show: false, //收银台
				pay_mode: 1, //支付模式 1=默认微信
				remark: '', //用户留言
				message_show: false,

				//物品信息
				goods_list: null, //物品信息
				insured_list: null, //保价列表
				weight_list: null, //重量配置
				goods_show: true,
				goods: {
					name: '', //物品信息
					price: 0, //物品价格
					weight: 0, //物品重量
					is_insured: 0, //是否保价
					is_incubator: 0, //是否需要保温箱
				},
				weight_index: 0, //物品重量选项序号
				insured_index: -1, //物品保价选项序号

				//返程信息
				return_remark: '', //返程内容
				is_return: '0', //返程金额

				//起送时间
				start_time: '',
				start_time_text: '立即送货',
				start_time_indexs: [0, 0, 0], //初始选中值
				start_time_show: false,
				start_time_picker: [
					['今天', '明天'],
					[],
					[]
				],

			};
		},
		props: {},
		onLoad(opt) {
			let _this = this;
			_this.order_mode = opt.order_mode;
			_this.applet = App.getApplet();
			_this.option();
		},
		onPageScroll(e) {
			// 页面滚动触发事件的处理函数
			const slideHeight = parseFloat(e.scrollTop.toFixed(0)); // 滑动距离
			if (slideHeight >= 50) {
				this.slideHeight = 1;
			} else {
				if (slideHeight <= 5) {
					this.slideHeight = 0;
				} else {
					let h = slideHeight / 50;
					this.slideHeight = parseFloat(h.toFixed(1))
				}
			}
		},
		methods: {
			
			/**
			 * 初始数据
			 */
			option: function() {
				let _this = this,
					address = App.getAddress();
				address.pages = 'index';
				uni.setStorageSync('address', address);
				
				//起点坐标
				let lat_lng = address.start.lat_lng;
				address.start.lat_lng = lat_lng.split(',');
				//目的地坐标
				lat_lng = address.receive.lat_lng;
				address.receive.lat_lng = lat_lng.split(',');
				
				//如果是帮你取
				if (_this.order_mode == 20) {
					_this.title = '帮我取';
					//替换起点与终点坐标
					let temp = address.start.lat_lng;
					address.start.lat_lng = address.receive.lat_lng;
					address.receive.lat_lng = temp;
				}
				_this.latitude = address.start.lat_lng[0];
				_this.longitude = address.start.lat_lng[1];
				_this.address = address;
				_this.getAttribute(); //获取物品属性
				_this.getUserDetail();//获取用户详情
				// #ifdef MP-WEIXIN
				_this.mp = 'weixin';
				_this.getTpl(); //获取模板消息
				// #endif
				// #ifdef MP-ALIPAY
				_this.mp = 'alipay';
				_this.pay_mode = 4; //支付宝支付
				//#endif
				// #ifdef H5
				_this.mp = uni.getStorageSync('browser') || '';
				if (_this.mp == 'alipay') {
					_this.pay_mode = 4;
				}
				// #endif
				_this.precreate(); //预生成订单
			},
			/**
			 * 预生成订单
			 */
			precreate: function() {
				let _this = this;
				_this.overturn();//处理坐标点
				let formData = {
					address: JSON.stringify(_this.address),
					goods: JSON.stringify(_this.goods), //物品
					is_return: _this.is_return, //是否返程
				}
				// 购物车结算
				App._post_form('order/precreate', formData, function(result) {
					_this.order = result.data;
				});
			},
			
			/**
			 * 设置送货时间
			 */
			startTime(e) {
				let _this = this;
				let indexs = e.indexs;
				let time = String(indexs[0]);
				let text = _this.start_time_picker[0][indexs[0]];
				_this.start_time_indexs = indexs;
				if (indexs[0] == 0 && indexs[1] == 0 && indexs[2] == 0) {
					text = '立即送货';
					time = ''
				} else {
					let h = String(_this.start_time_picker[1][indexs[1]]);
					let m = String(_this.start_time_picker[2][indexs[2]]);
					h = h.replace(/[\u65f6]+/g, '');
					m = m.replace(/[\u5206]+/g, '');
					time += ',' + String(h) + ',' + String(m);
					if (h == '0') {
						h = '00';
					}
					if (m == '0') {
						m = '00';
					}
					text += String(h) + ':' + String(m);
				}
				_this.start_time = time;
				_this.start_time_text = text;
				_this.start_time_show = false;
			},
			/**
			 * 关闭送货时间选择
			 */
			startTimeClose() {
				let _this = this;
				_this.start_time_show = false;
			},
			/**
			 * 开启送货时间选择
			 */
			startTimeOpen() {
				let _this = this;
				//初始化送货时间选项数据
				let timestamp = Date.now();
				let h = uni.$u.timeFormat(timestamp, 'hh'); //获取当前小时
				let m = uni.$u.timeFormat(timestamp, 'MM'); //分钟
				let arr = ['立即送货'];
				for (let n = h; n < 24; n++) {
					if (n == h && m < 30) {
						arr.push(n + '时');
					} else {
						arr.push(n + '时');
					}
				}
				_this.start_time_picker[1] = arr;
				_this.start_time_show = true;
			},

			/**
			 * 送货时间发生改变时
			 */
			startTimeHandler(e) {
				let _this = this;
				let start_time_picker = _this.start_time_picker;
				const {
					columnIndex,
					value,
					values, // values为当前变化列的数组内容
					indexs,
					index,
					// 微信小程序无法将picker实例传出来，只能通过ref操作
					picker = this.$refs.startTimePicker
				} = e
				//初始化送货时间选项数据
				let timestamp = Date.now();
				let h = uni.$u.timeFormat(timestamp, 'hh'); //获取当前小时
				let m = uni.$u.timeFormat(timestamp, 'MM'); //分钟
				let arr = [];
				let arr2 = [];
				// 当第一列值发生变化时，变化第二列(后一列)对应的选项
				//当滑动第1列
				if (columnIndex === 0) {
					if (index == 0) {
						arr.push('立即送货');
						for (let n = h; n < 24; n++) {
							if (n == h && m < 30) {
								arr.push(n + '时');
							} else {
								arr.push(n + '时');
							}
						}
					}
					if (index == 1) {
						for (let n = 0; n <= h; n++) {
							arr.push(n + '时');
						}
						arr2 = ['0分', '10分', '20分', '30分', '40分', '50分'];
					}
					start_time_picker[1] = arr;
					picker.setColumnValues(1, arr);
					start_time_picker[2] = arr2;
					_this.start_time_picker = start_time_picker;
					picker.setColumnValues(2, arr2);
				}
				//当滑动第2列
				if (columnIndex === 1) {
					//判断第一列选择得是不是第二个选项（明天）
					if (indexs[0] == 1) {
						//如果是最后一项
						let len = start_time_picker[1].length - 1;
						if (indexs[1] == len) {
							arr2 = ['0分'];
						} else {
							arr2 = ['0分', '10分', '20分', '30分', '40分', '50分'];
						}
					} else {
						//否则是第一个选项（今天）
						//判断是不是第二列得第2项
						if (indexs[1] == 1) {
							if (m < 30) {
								arr2 = ['30分', '40分', '50分'];
							} else {
								arr2 = ['0分', '10分', '20分'];
							}
						}
						//判断是不是第二列并大于第二项
						if (indexs[1] > 1) {
							arr2 = ['0分', '10分', '20分', '30分', '40分', '50分'];
						}
					}
					start_time_picker[2] = arr2;
					_this.start_time_picker = start_time_picker;
					picker.setColumnValues(2, arr2);
				}
			},
			/**
			 * 备注信息框显示
			 */
			messageShow() {
				let _this = this;
				_this.message_show = !_this.message_show;
			},
			/**
			 * 是否需要返程订单
			 */
			setReturn: function(e) {
				let _this = this;
				_this.is_return = e;
				if(e == 0){
					_this.return_remark = '';
				}
				_this.precreate(); //预生成订单
			},

			/**
			 * 返回上一页
			 */
			back: function() {
				let _this = this;
				uni.showModal({
					title: "是否取消下单？",
					content: "取消后信息将会被清除",
					success: function(o) {
						if (o.confirm) {
							uni.navigateBack();
						}
					}
				});
			},
			/**
			 * 设置支付方式
			 */
			setPay(e) {
				let _this = this;
				//如果是余额支付
				if (e == 2) {
					if (_this.userInfo.money < Number(_this.order.pay_price)) {
						return false;
					}
				}
				_this.pay_mode = e;
			},
			/**
			 * 订阅消息
			 */
			subMsg: function() {
				let _this = this;
				if (_this.goods_name == '') {
					_this.cashier_show = false;
					App.showError('请完善物品信息');
					return false;
				}
				if (_this.order.intra_region) {
					_this.cashier_show = false;
					App.showError('当前地址超出配送范围');
					return false;
				}
				// #ifdef MP-WEIXIN
				//开启订阅消息
				uni.requestSubscribeMessage({
					tmplIds: _this.tpl,
					complete(res) {
						_this.payment();
						return true;
					}
				});
				//#endif
				// #ifdef H5 || MP-ALIPAY
				_this.payment();
				//#endif
			},
			/**
			 * 订单提交
			 */
			payment: function() {
				let _this = this,
					formData = _this.order;
				formData.distance = formData.distance.value; //配送距离（米）
				formData.estimate_time = formData.estimate_time.value; //到达所需时间（分钟）
				
				//判断支付金额是否为0
				if (formData.pay_price == 0) {
					_this.pay_mode = 2; //余额支付
				}
				formData.order_mode = _this.order_mode;
				formData.pay_mode = _this.pay_mode;
				formData.start_time = _this.start_time; //配送时间
				formData.remark = _this.remark; //用户备注
				formData.is_return = _this.is_return; //是否返程
				formData.return_remark = _this.return_remark; //返程信息
				formData.goods = JSON.stringify(_this.goods); //物品信息
				formData.address = JSON.stringify(_this.address); //数组转换为json

				// #ifdef H5
				formData.browser = _this.mp;
				// #endif

				// 订单创建成功后回调
				let callback = function(result) {
					console.log(result);
					_this.cashier_show = false; //关闭结算框
					//如果支付未成功
					if (result.code === -10) {
						App.showError(result.msg, function() {
							App.goTo('order/detail?id=' + result.data.order_id); // 跳转到订单详情
						});
						return false;
					}
					//如果是余额
					if (_this.pay_mode == 2) {
						App.showSuccess('下单成功', function() {
							App.goTo('order/detail?id=' + result.data.order_id); // 跳转到订单详情
						});
						return true;
					}
					// 发起微信支付
					// #ifdef MP-WEIXIN
					//开启订阅消息
					uni.requestPayment({
						timeStamp: result.data.payment.timeStamp,
						nonceStr: result.data.payment.nonceStr,
						package: result.data.payment.package,
						signType: result.data.payment.signType,
						paySign: result.data.payment.paySign,
						success: function(res) {
							App.showSuccess('支付成功', function() {
								App.goTo('order/detail?id=' + result.data.order_id); // 跳转到订单详情
							});
						},
						fail: function(res) {
							let msg = '支付失败';
							if (res.errMsg == 'requestPayment:fail cancel') {
								msg = '用户取消支付';
							}
							App.showError(msg, function() {
								App.goTo('order/detail?id=' + result.data.order_id); // 跳转到订单详情
							});
						}
					});
					//#endif
					//#ifdef H5
					//微信支付
					if (_this.pay_mode == 1) {
						if (_this.mp == 'weixin') {
							WeixinJSBridge.invoke('getBrandWCPayRequest', {
								'appId': result.data.payment.appId,
								'timeStamp': result.data.payment.timeStamp,
								'nonceStr': result.data.payment.nonceStr,
								'package': result.data.payment.package,
								'signType': result.data.payment.signType,
								'paySign': result.data.payment.paySign
							}, function(res) {
								let msg = '支付成功';
								if (res.err_msg === 'get_brand_wcpay_request:ok') {
									//支付成功
									App.showSuccess('支付成功', function() {
										App.goTo('order/detail?id=' + result.data
											.order_id); // 跳转到订单详情
									});
									return true;
								} else if (res.err_msg === 'get_brand_wcpay_request:cancel') {
									msg = '用户取消支付';
								} else if (res.err_msg === 'get_brand_wcpay_request:fail') {
									msg = '支付失败';
								}
								App.showError(msg, function() {
									App.goTo('order/detail?id=' + result.data.order_id); // 跳转到订单详情
								});
							});
						}
						if (_this.mp == 'other') {
							document.location.href = result.data.payment;
						}
					}
					//支付宝支付
					if (_this.pay_mode == 4) {
						const div = document.createElement('div');
						div.innerHTML = result.data.payment;
						document.body.appendChild(div);
						document.forms['alipaysubmit'].submit();
					}
					//#endif
					// #ifdef MP-ALIPAY
					uni.requestPayment({
						orderInfo: result.data.payment.trade_no,
						success: function(res) {
							if (res.resultCode != '9000') {
								App.showError(res.memo);
								return false;
							}
							App.showSuccess('支付成功', function() {
								App.goTo('order/detail?id=' + result.data.order_id); // 跳转到订单详情
							});
						}
					});
					//#endif
				};

				// 创建订单-购物车结算
				App._post_form('order/add', formData, function(result) {
					callback(result);
				}, function(result) {
					// fail
				}, function() {
					// complete
				});
			},

			/**
			 * 翻转坐标
			 * e = 是否翻转
			 */
			overturn: function(e = false) {
				let _this = this,
					address = _this.address;
				//是否翻转
				if (e) {
					let temp = address.start;
					address.start = address.receive;
					address.receive = temp;
					_this.latitude = address.start.lat_lng[0];
					_this.longitude = address.start.lat_lng[1];
					_this.address = address;
				}
				_this.markers = [{
					id: 1,
					latitude: address.start.lat_lng[0],
					longitude: address.start.lat_lng[1],
					iconPath: '/static/fa.png',
					width: 40,
					height: 40,
				}, {
					id: 2,
					latitude: address.receive.lat_lng[0],
					longitude: address.receive.lat_lng[1],
					iconPath: '/static/shou.png',
					width: 40,
					height: 40,
				}];
				_this.polyline = [{
					points: [{
							latitude: address.start.lat_lng[0],
							longitude: address.start.lat_lng[1],
						},
						{
							latitude: address.receive.lat_lng[0],
							longitude: address.receive.lat_lng[1],
						}
					],
					color: '#19be6b',
					width: 5,
				}];
				let mapContext = uni.createMapContext('map1');//地图
				//中心点偏移
				mapContext.setCenterOffset({
					offset: [0.4, 0.25]
				});
			},

			/**
			 * 物品信息框是否显示
			 */
			goodsShow: function() {
				let _this = this;
				if(_this.goods_show){
					_this.precreate(); //预生成订单
				}
				_this.goods_show = !_this.goods_show;
			},
			/**
			 * 设置物品类型
			 */
			setGoodsName: function(name) {
				let _this = this;
				_this.goods.name = name;
			},
			/**
			 * 设置物品保价
			 */
			setGoodsInsured: function(index) {
				let _this = this;
				if (_this.insured_index == index) {
					_this.insured_index = -1;
					_this.goods.is_insured = 0;
					_this.goods.price = '';
				} else {
					_this.insured_index = index;
					_this.goods.is_insured = 1;
					_this.goods.price = _this.insured_list[index].value;
				}
			},
			/**
			 * 设置物品重量
			 */
			setGoodsWeight: function(index) {
				let _this = this;
				_this.weight_index = index;
				_this.goods.weight = _this.weight_list[index].value;
			},
			/**
			 * 是否需要保温箱
			 */
			setGoodsIncubator:function(value){
				let _this = this;
				_this.goods.is_incubator = value;
			},
			/**
			 * 获取物品属性
			 */
			getAttribute: function() {
				let _this = this;
				App._get('order/goodsAttribute', {}, function(result) {
					_this.goods_list = result.data.goods;
					_this.weight_list = result.data.weight;
					_this.insured_list = result.data.insured;
				});
			},
			/**
			 * 获取订阅消息配置
			 */
			getTpl: function() {
				let _this = this;
				App._get('setting/tpl', {}, function(result) {
					_this.tpl = result.data;
				});
			},
			/**
			 * 获取当前用户信息
			 */
			getUserDetail: function() {
				let _this = this;
				App._get('user/detail', {}, result => {
					_this.userInfo = result.data;
				});
			},
		}
	};
</script>
<style lang="scss" scoped>
	map {
		width: 750rpx;
		height: 100vh;
		position: fixed;
		top: 0;
		left: 0;
	}

	.goods-scroll {
		width: 100%;
		height: calc(100vh - 500rpx);

		.goods-type {
			margin-top: 20rpx;

			.item {
				margin-top: 20rpx;
				margin-left: 20rpx;
				display: inline-block;
				width: 29%;
				line-height: 80rpx;
				text-align: center;
				border-radius: 20rpx;
			}

			.default {
				border: 1rpx solid #c0c4cc;
			}

			.selected {
				border: 1rpx solid #ff6900;
				color: #ff6900;
				background-color: #fdf6ec;
			}
		}

		.goods-insured {
			margin-top: 20rpx;

			.item {
				margin-top: 20rpx;
				margin-left: 20rpx;
				display: inline-block;
				width: 45%;
				padding: 20rpx 0rpx;
				text-align: center;
				border-radius: 20rpx;

				.value {
					color: #909193;
					font-size: 24rpx;
				}

				.price {
					font-size: 28rpx;
				}
			}

			.default {
				border: 1rpx solid #c0c4cc;
			}

			.selected {
				border: 1rpx solid #ff6900;
				background-color: #fdf6ec;
			}
		}

		.goods-weight {
			margin-top: 20rpx;

			.item {
				margin-top: 20rpx;
				margin-left: 20rpx;
				display: inline-block;
				width: 21%;
				padding: 20rpx 0rpx;
				text-align: center;
				border-radius: 20rpx;

				.value {
					color: #909193;
					font-size: 24rpx;
				}

				.price {
					font-size: 28rpx;
				}
			}

			.default {
				border: 1rpx solid #c0c4cc;
			}

			.selected {
				border: 1rpx solid #ff6900;
				background-color: #fdf6ec;
			}
		}
	}

	.scroll {
		width: 100%;
		height: 100%;
		padding-top: 650rpx;

		.header {
			position: fixed;
			display: flex;
			left: 0rpx;
			top: 0rpx;
			height: 180rpx;
			width: 100%;
			z-index: 9999;

			.title {
				width: 100%;
				margin-top: 90rpx;
				text-align: center;
				line-height: 100rpx;

				text {
					margin-left: -150rpx;
				}

				.return {
					display: inline-block;
					height: 70rpx;
					width: 70rpx;
					background-color: #fff;
					border-radius: 50%;
					float: left;
					margin-top: 30rpx;
					margin-left: 40rpx;

					.icons {
						float: left;
						margin: 15rpx 0rpx 0rpx 12rpx;
					}
				}
			}
		}

		.content {
			background-color: #f3f4f6;
			padding: 0rpx 20rpx 40rpx 20rpx;
			margin-top: 80rpx;

			.body {
				position: relative;
				top: -80rpx;

				.address {
					background-color: #ffffff;
					padding: 0rpx 20rpx 20rpx 20rpx;
					border-radius: 18rpx;
				}

				.form-item {
					font-size: 30rpx;
					padding: 30rpx 0rpx;

					.right {
						display: inline-block;
						float: right;
					}

					.w-50 {
						display: inline-block;
						width: 49.7%;
						text-align: center;
					}
				}
			}
		}

		.hm-footer-fixed {
			padding: 20rpx;

			.footer-but {
				width: 100%;
				height: 100rpx;
				line-height: 100rpx;
				color: #ffffff;

				.but-left {
					background-color: #000000;
					width: 70%;
					display: inline-block;
					border-top-left-radius: 50rpx;
					border-bottom-left-radius: 50rpx;
					float: left;
					height: 100rpx;

					.price {
						margin-left: 40rpx;
						font-weight: 900;
						font-size: 45rpx;

						text {
							font-size: 32rpx;
						}

						float: left;
					}

					.icons {
						float: left;
						display: inline-block;
						margin-left: 10rpx;
						margin-top: 35rpx;
						width: 32rpx;
						height: 32rpx;
						line-height: 22rpx;
						text-align: center;
						border-radius: 50%;
						background: rgba(255, 255, 255, 0.3);
					}
				}

				.but-right {
					background-color: #ff6900;
					width: 30%;
					display: inline-block;
					text-align: center;
					border-top-right-radius: 50rpx;
					border-bottom-right-radius: 50rpx;
				}
			}
		}
	}
</style>